import dayjs from 'dayjs'
export const getTime = () => {
  const getToday = () => {
    //获取本日
    const today = dayjs()
    const startDate = today.format('YYYY-MM-DD')
    const endDate = today.format('YYYY-MM-DD')
    return [startDate, endDate]
  }
  const getWeek = () => {
    //获取本周
    const today = dayjs().subtract(1, 'day')
    const startWeek = today.startOf('week').add(1, 'day').format('YYYY-MM-DD')
    const endWeek = today.endOf('week').add(1, 'day').format('YYYY-MM-DD')
    return [startWeek, endWeek]
  }
  const getMonth = () => {
    //获取本月
    const today = dayjs()
    const startMonth = today.startOf('month').format('YYYY-MM-DD')
    const endMonth = today.endOf('month').format('YYYY-MM-DD')
    // const startMonth = dayjs().month(dayjs().month()).startOf('month').format('YYYY-MM-DD')
    // const endMonth = dayjs().month(dayjs().month()).endOf('month').format('YYYY-MM-DD')
    return [startMonth, endMonth]
  }
  return {
    getToday,
    getWeek,
    getMonth
  }
}
